﻿<navigation:Page x:Class="DeepTime.BootStrapper.Views.Home" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
           d:DesignWidth="640" d:DesignHeight="480"
           xmlns:Utilities="clr-namespace:DeepTime.BootStrapper.Utilities"
                 xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
           Title="Home Page">
    <navigation:Page.Resources>
        <Utilities:BlobUriToImageURLConverter x:Name="BlobUriToImageURL" />
    </navigation:Page.Resources>

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <Style TargetType="Button">
                <Setter Property="Height" Value="50" />
                <Setter Property="Width" Value="100" />
                <Setter Property="Margin" Value="0,0,5,0" />
            </Style>
        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <StackPanel Orientation="Horizontal">
            <Button Content="Upload" Click="Button_Click" HorizontalAlignment="Left" VerticalAlignment="Top" />
            <Button Content="DeepZooms" Click="Button_Click_2"  HorizontalAlignment="Left" VerticalAlignment="Top" />
            <ItemsControl Name="icUploaders" ItemsSource="{Binding}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Progress}" Margin="5,0,0,0" />
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </StackPanel>

        <ListBox Name="lbImages" Grid.Row="1" ItemsSource="{Binding}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <!--<TextBlock Text="{Binding BlobUri}" />-->
                        <Image Utilities:ImageExtensionBehaviours.RelativeSource="{Binding BlobUri, Mode=OneWay, Converter={StaticResource BlobUriToImageURL}}" Height="200" Width="200" 
                               HorizontalAlignment="Left" />
                        <Button Click="Button_Click_3" Content="Add to Canvas" Width="Auto" />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <my:WrapPanel />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>            
        </ListBox>

        <StackPanel Orientation="Horizontal" Grid.Column="1">
            <Button Content="Clear" Click="Button_Click_1"  HorizontalAlignment="Left" VerticalAlignment="Top" />
            <Button Content="Generate" Click="Button_Click_4"  HorizontalAlignment="Left" VerticalAlignment="Top" />
        </StackPanel>

        <Canvas Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="cCollage">
        </Canvas>
    </Grid>
</navigation:Page>
